import React,{useCallback,useMemo,useState} from "react";

function UseCallbackView(){
    // console.log("组件被更新了");
    const [one,setOne]=useState(1),
          [tow,setTow]=useState(1);
     const memoizedCallback=useCallback(()=>{
        // console.log(one,tow);
        console.log(memoizedValue);
        return (one+tow)
    },[one,tow])
    const memoizedValue = useMemo(() =>
    {
       console.log(one,tow);
        // return (one+tow)
    }
    , [one+tow]);
  
    return (
        <div>
             <button  className="bg_409EFF pd_20 c_fff border_radius_4 mg_t_20" onClick={()=>{
                 setOne(state=>(++state))
             }}>{one}</button>
            <div>
                <button  className="bg_409EFF pd_20 c_fff border_radius_4 mg_t_20" onClick={()=>{
                 setOne(state=>(++state))
             }}>{tow}</button>
            </div>
            <div className="pd_20">{memoizedCallback()}</div>
            {/* <div className="pd_20">{memoizedValue()()}</div> */}
        </div>
    )
}

export default UseCallbackView;